﻿ function initData(tableid, typeid){
     //alert('initData.........');
     $.ajax({
         type:'get',
         dateType: "json",
         url:"/contract/findWorkPlan",
         data:{
             level1SystemId: tableid,
                    typeId: typeid
              },
         success:function(res){
             console.log(res);
             if(res.msg == 'success') {
                 layer.msg("加载数据成功");
                 setData(res.data.workPlan);
             } else {
                 layer.msg('加载数据失败');
             }
         },
         error:function(){
            alert("测试");
            //testData();
         }
     });
 }


 function isEmpty(val){
     if(val == null || val == 'undefined' || val == '' || val == 'null'){
         return "";
     } else {
         return val;
     }
 }

 function setData(info){
     var pmIndex = 1;
     var jszxIndex = 1;
     var appDesignerIndex = 1;
     var platformDesignerIndex = 1;
     var clientDesignerIndex = 1;
     var webDesignerIndex = 1;
     var uiDesignerIndex = 1;
     var javaDesignerIndex = 1;
     var andriodDesignerIndex = 1;
     var AppDesignerIndex = 1;
     var CDesignerIndex = 1;
     var webDesigner2Index = 1;
     var testIndex = 1;
     var bmIndex = 1;
     var implementIndex = 1;
     var projectDirectorIndex = 1;
     var techDirectorIndex = 1;
     for(let i=0; i < info.length; i++){
         switch(info[i].site){
             case 1: {
                 var pmNum = info[i].num;
                 $("#pm_num").attr("value", pmNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#pm_num").dispatchEvent(evtObj);
                         $('#pm_money').val(info[i].money);
                         $('#pm_name_'+pmIndex).attr("value", isEmpty(info[i].name));
                         $('#pm_num_'+pmIndex).attr("value", info[i].planDay);
                         $('#pm_totalnum_'+pmIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 2: {
                 var jszxNum = info[i].num;
                 $("#jszx_num").attr("value", jszxNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#jszx_num").dispatchEvent(evtObj);
                         $('#jszx_money').val(info[i].money);
                         $('#jszx_name_'+jszxIndex).attr("value", isEmpty(info[i].name));
                         $('#jszx_num_'+jszxIndex).attr("value", info[i].planDay);
                         $('#jszx_totalnum_'+jszxIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 3: {
                 var appDesignerNum = info[i].num;
                 $("#app_designer_num").attr("value", appDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#app_designer_num").dispatchEvent(evtObj);
                         $('#app_designer_money').val(info[i].money);
                         $('#app_designer_name_'+appDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#app_designer_num_'+appDesignerIndex).attr("value", info[i].planDay);
                         $('#app_designer_totalnum_'+appDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 4: {
                 var platformDesignerNum = info[i].num;
                 $("#platform_designer_num").attr("value", platformDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#platform_designer_num").dispatchEvent(evtObj);
                         $('#platform_designer_money').val(info[i].money);
                         $('#platform_designer_name_'+platformDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#platform_designer_num_'+platformDesignerIndex).attr("value", info[i].planDay);
                         $('#platform_designer_totalnum_'+platformDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 5:{
                 var clientDesignerNum = info[i].num;
                 $("#client_designer_num").attr("value", clientDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#client_designer_num").dispatchEvent(evtObj);
                         $('#client_designer_money').val(info[i].money);
                         $('#client_designer_name_'+clientDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#client_designer_num_'+clientDesignerIndex).attr("value", info[i].planDay);
                         $('#client_designer_totalnum_'+clientDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 6:{
                 var webDesignerNum = info[i].num;
                 $("#web_designer_num").attr("value", webDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#web_designer_num").dispatchEvent(evtObj);
                         $('#web_designer_money').val(info[i].money);
                         $('#web_designer_name_'+webDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#web_designer_num_'+webDesignerIndex).attr("value", info[i].planDay);
                         $('#web_designer_totalnum_'+webDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 7:{
                 var uiDesignerNum= info[i].num;
                 $("#ui_designer_num").attr("value", uiDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#ui_designer_num").dispatchEvent(evtObj);
                         $('#ui_designer_money').val(info[i].money);
                         $('#ui_designer_name_'+uiDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#ui_designer_num_'+uiDesignerIndex).attr("value", info[i].planDay);
                         $('#ui_designer_totalnum_'+uiDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 8:{
                 var javaDesignerNum= info[i].num;
                 $("#java_designer_num").attr("value", javaDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#java_designer_num").dispatchEvent(evtObj);
                         $('#java_designer_money').val(info[i].money);
                         $('#java_designer_name_'+javaDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#java_designer_num_'+javaDesignerIndex).attr("value", info[i].planDay);
                         $('#java_designer_totalnum_'+javaDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 9:{
                 var andriodDesignerNum= info[i].num;
                 $("#andriod_designer_num").attr("value", andriodDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#andriod_designer_num").dispatchEvent(evtObj);
                         $('#andriod_designer_money').val(info[i].money);
                         $('#andriod_designer_name_'+andriodDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#andriod_designer_num_'+andriodDesignerIndex).attr("value", info[i].planDay);
                         $('#andriod_designer_totalnum_'+andriodDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 10:{
                 var AppDesignerNum= info[i].num;
                 $("#App_designer_num").attr("value", AppDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#App_designer_num").dispatchEvent(evtObj);
                         $('#App_designer_money').val(info[i].money);
                         $('#App_designer_name_'+AppDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#App_designer_num_'+AppDesignerIndex).attr("value", info[i].planDay);
                         $('#App_designer_totalnum_'+AppDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 11:{
                 var CDesignerNum= info[i].num;
                 $("#C_designer_num").attr("value", CDesignerNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#C_designer_num").dispatchEvent(evtObj);
                         $('#C_designer_money').val(info[i].money);
                         $('#C_designer_name_'+CDesignerIndex).attr("value", isEmpty(info[i].name));
                         $('#C_designer_num_'+CDesignerIndex).attr("value", info[i].planDay);
                         $('#C_designer_totalnum_'+CDesignerIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 12:{
                 var webDesigner2Num= info[i].num;
                 $("#web_designer_2_num").attr("value", webDesigner2Num);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#web_designer_2_num").dispatchEvent(evtObj);
                         $('#web_designer_2_money').val(info[i].money);
                         $('#web_designer_2_name_'+webDesigner2Index).attr("value", isEmpty(info[i].name));
                         $('#web_designer_2_num_'+webDesigner2Index).attr("value", info[i].planDay);
                         $('#web_designer_2_totalnum_'+webDesigner2Index++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 13: {
                 var testNum = info[i].num;
                 $("#test_num").attr("value", testNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#test_num").dispatchEvent(evtObj);
                         $('#test_money').val(info[i].money);
                         $('#test_name_'+testIndex).attr("value", isEmpty(info[i].name));
                         $('#test_num_'+testIndex).attr("value", info[i].planDay);
                         $('#test_totalnum_'+testIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 14: {
                 var bmNum = info[i].num;
                 $("#bm_num").attr("value", bmNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#bm_num").dispatchEvent(evtObj);
                         $('#bm_money').val(info[i].money);
                         $('#bm_name_'+bmIndex).attr("value", isEmpty(info[i].name));
                         $('#bm_num_'+bmIndex).attr("value", info[i].planDay);
                         $('#bm_totalnum_'+bmIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 15: {
                 var implement = info[i].num;
                 $("#implement_num").attr("value", implement);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#implement_num").dispatchEvent(evtObj);
                         $('#implement_money').val(info[i].money);
                         $('#implement_name_'+implementIndex).attr("value", isEmpty(info[i].name));
                         $('#implement_num_'+implementIndex).attr("value", info[i].planDay);
                         $('#implement_totalnum_'+implementIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 16: {
                 var projectDirectorNum = info[i].num;
                 $("#project_director_num").attr("value", projectDirectorNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#project_director_num").dispatchEvent(evtObj);
                         $('#project_director_money').val(info[i].money);
                         $('#project_director_name_'+projectDirectorIndex).attr("value", isEmpty(info[i].name));
                         $('#project_director_num_'+projectDirectorIndex).attr("value", info[i].planDay);
                         $('#project_director_totalnum_'+projectDirectorIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
             case 17: {
                 var techDirectorNum = info[i].num;
                 $("#tech_director_num").attr("value", techDirectorNum);
                 setTimeout(
                     function(){
                         var evtObj = document.createEvent('UIEvents');
                         evtObj.initUIEvent('input', true, true, window, 1 );
                         document.querySelector("#tech_director_num").dispatchEvent(evtObj);
                         $('#tech_director_money').val(info[i].money);
                         $('#tech_director_name_'+techDirectorIndex).attr("value", isEmpty(info[i].name));
                         $('#tech_director_num_'+techDirectorIndex).attr("value", info[i].planDay);
                         $('#tech_director_totalnum_'+techDirectorIndex++).attr("value", info[i++].totalDay);
                     },10)}
                 break;
         }
     }
 }




